<script setup lang="ts">
import type { Props } from './index.d'

const props = defineProps<Props>()

const url = ref('')

watch(
  () => props.url,
  () => fetchImageUrl(),
  {
    immediate: true,
  },
)

// 获取图片
async function fetchImageUrl() {
  if (!props.module) {
    url.value = props.url
    return
  }
  url.value = await fetchImages(props.url, props.module)
}
</script>

<template>
  <img v-lazy="url" class="width-fill" alt="图表图片">
</template>
